package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1023 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public List<Boolean> camelMatch(String[] queries, String pattern) {
            List<Boolean> res = new ArrayList<>(queries.length);
            for (String query : queries) {
                String other = getOther(query, pattern);
                if (other.equals("")) {
                    res.add(false);
                } else {
                    res.add(other.toLowerCase().equals(other));
                }
            }
            return res;
        }

        private String getOther(String query, String pattern) {
            int index = 0;
            StringBuilder sb = new StringBuilder("a"); // 避免两个串相等时返回""
            for (int i = 0; i < pattern.length(); i++) {
                char t = pattern.charAt(i);
                int index2 = query.indexOf(t, index);
                if (index2 < 0) {
                    return "";
                }
                sb.append(query, index, index2);
                index = index2 + 1;
            }
            sb.append(query.substring(index));
            return sb.toString();
        }
    }


    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC1023 an = new LC1023();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
